// import { BrowserRouter as Router, Route, Routes, Navigate, useRoutes } from 'react-router';
// import Login from '../Pages/Login';
// // import NoteBook from '../Pages/NoteBook';

// const routes = [
//     {
//         path: '/',
//         element: <Navigate to="/noteBook" />
//     },
//     {
//         path: '/login',
//         element: <Login />
//     },
// ];

// export default function WrapperRouter() {
//     return (
//         <Router>{useRoutes(routes)}</Router>
//     );
// }
import { BrowserRouter as Router, Route, Routes, Navigate, useRoutes } from 'react-router';
import { lazy, } from 'react';
// import NoteBook from '../Pages/NoteBook';
const Login = lazy(() => import('../Pages/Login'));
// const noteBook = lazy(() => import('../Pages/noteBook'));
const Home = lazy(() => import('../Pages/Home'));

const routes = [
    {
        path: '/noteBook',
        element: <Navigate to="/noteBook" />
    },
    {
        path: '/home',
        element: <Home />
    },
    {
        path: '/login',
        element: <Login />
    },
];

// 创建一个子组件来使用 useRoutes
// useRoutes这个钩子函数只能用在路由组件中，也就是说该组件不能被抛出
function WrapperRoutes() {
    return useRoutes(routes);
}

export default function WrapperRouter() {
    return (
        <Router>
            <WrapperRoutes />
        </Router>
    );
}